﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using uAccess;
using WebApi.Models;

namespace WebApi.Services
{
    public class MyLogin
    {
        public static JObject adlogin(string ad_id,string ad_password)
        {  
           var op = new uAccess<Administrators>("dbConnect");
           var pr = op.GetFirst(c => c.Adm_Id ==ad_id);


           if(pr==null)
            {
                JObject ad_state_null = new JObject
                {
                {"ad_state",0}
                };
                return ad_state_null;
            }


           var state = 0;
            if (pr.Adm_Pwd==ad_password)
            {
                state = 1;
            }
          
            JObject ad_state = new JObject
            {
                {"ad_state",state}
            };
           return ad_state;
        }
    }
}
